package com.binance.notification.web.service.abnormaltrade.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.binance.notification.data.mapper.AbnormalTradeNoticeLogMapper;
import com.binance.notification.data.models.AbnormalTradeNoticeLogModel;
import com.binance.notification.web.service.abnormaltrade.IAbnormalTradeNoticeLogService;
import com.binance.notification.web.service.abnormaltrade.convert.AbnormalTradeNoticeLogConvertor;
import com.binance.notification.web.service.abnormaltrade.models.AbnormalTradeNoticeLogBo;
import com.google.common.collect.Maps;

@Service
public class AbnormalTradeNoticeLogServiceImpl implements IAbnormalTradeNoticeLogService {

    @Autowired
    private AbnormalTradeNoticeLogMapper abnormalTradeNoticeLogDao;

    @Override
    public int addOrUpdateAbnormalTradeNoticeLog(AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo) {
        AbnormalTradeNoticeLogModel abnormalTradeNoticeLogModel =
                AbnormalTradeNoticeLogConvertor.toDo(abnormalTradeNoticeLogBo);
        return abnormalTradeNoticeLogDao.insertOnDuplicateKeyUpdate(abnormalTradeNoticeLogModel);
    }

//    @Override
//    public List<AbnormalTradeNoticeLogBo> findBySymbolAndBusinessType(String symbol, String businessType) {
//        Map<String, Object> param = Maps.newHashMap();
//        param.put("symbol", symbol);
//        param.put("businessType", businessType);
//        List<AbnormalTradeNoticeLogModel> abnormalTradeNoticeLogModel =
//                abnormalTradeNoticeLogDao.findBySymbolAndBusinessType(param);
//        if (CollectionUtils.isEmpty(abnormalTradeNoticeLogModel)) {
//            return null;
//        }
//        List<AbnormalTradeNoticeLogBo> abnormalTradeNoticeLogBoList =
//                AbnormalTradeNoticeLogConvertor.toBoList(abnormalTradeNoticeLogModel);
//        return abnormalTradeNoticeLogBoList;
//    }

    @Override
    public AbnormalTradeNoticeLogBo findBySymbolAndBusinessTypeAndDescCode(String symbol, String businessType,
            String descCode) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("symbol", symbol);
        param.put("businessType", businessType);
        param.put("descCode", descCode);
        AbnormalTradeNoticeLogModel abnormalTradeNoticeLogModel =
                abnormalTradeNoticeLogDao.findBySymbolAndBusinessTypeAndDescCode(param);
        if (null == abnormalTradeNoticeLogModel) {
            return null;
        }
        AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo =
                AbnormalTradeNoticeLogConvertor.toBo(abnormalTradeNoticeLogModel);
        return abnormalTradeNoticeLogBo;
    }

//    @Override
//    public AbnormalTradeNoticeLogBo findById(String id) {
//        AbnormalTradeNoticeLogModel abnormalTradeNoticeLogModel = abnormalTradeNoticeLogDao.selectByPrimaryKey(id);
//        if (null == abnormalTradeNoticeLogModel) {
//            return null;
//        }
//        AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo =
//                AbnormalTradeNoticeLogConvertor.toBo(abnormalTradeNoticeLogModel);
//        return abnormalTradeNoticeLogBo;
//    }

//    @Override
//    public int updateAbnormalTradeNoticeLog(AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo) {
//        AbnormalTradeNoticeLogModel abnormalTradeNoticeLogModel =
//                AbnormalTradeNoticeLogConvertor.toDo(abnormalTradeNoticeLogBo);
//        int result = abnormalTradeNoticeLogDao.updateByPrimaryKeySelective(abnormalTradeNoticeLogModel);
//        return result;
//    }

//    @Override
//    public List<AbnormalTradeNoticeLogBo> findByBusinessType(String businessType, Integer page, Integer offset) {
//        Map<String, Object> param = Maps.newHashMap();
//        param.put("businessType", businessType);
//        param.put("page", page);
//        param.put("offset", offset);
//        List<AbnormalTradeNoticeLogModel> abnormalTradeNoticeLogModel =
//                abnormalTradeNoticeLogDao.findByBusinessType(param);
//        if (CollectionUtils.isEmpty(abnormalTradeNoticeLogModel)) {
//            return Lists.newArrayList();
//        }
//        List<AbnormalTradeNoticeLogBo> abnormalTradeNoticeLogBoList =
//                AbnormalTradeNoticeLogConvertor.toBoList(abnormalTradeNoticeLogModel);
//        return abnormalTradeNoticeLogBoList;
//    }

//    @Override
//    public List<AbnormalTradeNoticeLogBo> getPageList(Integer page, Integer offset) {
//        Map<String, Object> param = Maps.newHashMap();
//        param.put("page", page);
//        param.put("offset", offset);
//        List<AbnormalTradeNoticeLogModel> abnormalTradeNoticeLogModel =
//                abnormalTradeNoticeLogDao.findByBusinessType(param);
//        if (CollectionUtils.isEmpty(abnormalTradeNoticeLogModel)) {
//            return Lists.newArrayList();
//        }
//        List<AbnormalTradeNoticeLogBo> abnormalTradeNoticeLogBoList =
//                AbnormalTradeNoticeLogConvertor.toBoList(abnormalTradeNoticeLogModel);
//        return abnormalTradeNoticeLogBoList;
//    }
}
